package demo

import (
    //"fmt"
	//"encoding/json"
	"thirdpaysdk/api/wisecashier"
	//"github.com/astaxie/beego"
)

func main() {
    
	//wisecashier.MicroAppPay()
	privateKeyFile := "hipopay_prod_public.key"
    keyPEMBlock, err := ioutil.ReadFile(privateKeyFile)  //读取RSA私钥进文件到字节数组
    if err != nil {
        return
    }
	
	payNotify := `{"status":"PAID","openid":"obdix0tUPUSugPA9CxhKyhy7OSSM","trade_type":"MINIPROGRA","exchange_rate":"1.0","no":"2019010714453170622459875","currency":"CNY","amount":"0.01","trade_time":"2019-01-07 14:45:32","pay_currency":"CNY","pay_amount":"0.01","agent_order_id":"302146260175949824"}`
	
	signature := `sAXMZGbungW0Z9ZEoV68cm7jEEJQ0A4ZR4KQsbA+iQ7J9ND1OQzPqBn/gkyr+g9TPHezSr3BPB5l/kQKWShkMaQx1WPNOBZicaAvq6dzD6VPT/G8KzUCw2PburI9qgEG/J0uuFfECNJZMhEzEgT3x86eTnLJr2dDjZVLPQNpcH+qhazoLsu7/6qBMWCdB+U/Rh2dy98aJmxq5cw6lWAuWRGtVS16fnwkfaztiAi0E/eND+zqnoBYftidRXN159ee+gO0zy2eXJnSbtXTxGX73beP7Wt1KK30PSGeSKDhWw1S7/3B6ygCHO7DJQ6MVZ7Ta4qoWpAViO2QiMw1MTsRrw==`
	
	var timeStampTmp int64 = 1546843548
	
	var v wisecashier.WisecashierMsg
	err = json.Unmarshal([]byte(payNotify), &v)
	if err != nil {
	    beego.Debug("Unmarshal err:", err.Error())
	}
	reqMap, err := wisecashier.WisecashierNotify(&v,[]byte(keyPEMBlock),[]byte(signature), timeStampTmp)
	if err != nil {
	    beego.Debug("WisecashierNotify err:", err.Error())
	}
	for key, value := range reqMap {
	    beego.Debug("key, value :", key, value)
	}
	
}
